package com.example.ying.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.ying.model.domain.Movie;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface MovieMapper extends BaseMapper<Movie> {


    // 从rate表获取用户评分最高的三部电影
    @Select("SELECT movie_id FROM rate where id = #{userId} order by rate desc limit 3")
    List<Integer> getTop3MoviesByUserId(String userId);


    // 根据豆瓣id查询电影信息
    @Select("SELECT * FROM movie where douban_id = #{doubanId}")
    Movie selectBydoubanId(int doubanId);

    // 根据豆瓣id查询电影评分
    @Select("SELECT rate FROM movie where douban_id = #{movieId}")
    Integer selectRateBydoubanId(Integer movieId);


}
